<?php

namespace mpend\modules\passport\controllers;

use Yii;
use mpend\components\Controller;
use mpend\modules\passport\models\BindMobileForm;

/**
 * 帐号绑定信息
 * @author emhome <emhome@163.com>
 * @since 2.0
 */
class BindController extends Controller {

    /**
     * @inheritdoc
     */
    protected function verbs() {
        return [
            '*' => ['POST'],
        ];
    }

    /**
     * @inheritdoc
     */
    protected function rules() {
        return [
            [
                'actions' => ['mobile'],
                'allow' => true,
                'roles' => ['@'],
            ],
            [
                'allow' => true,
            ]
        ];
    }

    /**
     * 绑定手机号
     * @return mixed
     */
    public function actionMobile() {
        $model = new BindMobileForm();
        if (!$model->load(Yii::$app->request->post(), '')) {
            parent::error('缺少绑定手机号必要的参数信息');
        }
        $model->token = $this->token;
        return $model->bind();
    }

}
